package com.hb.common.util;

import com.hb.common.handler.os.OSHandler;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class OSUtil {

    @Resource
    private List<OSHandler> osHandlers;

    private static final String OS = System.getProperty("os.name").toLowerCase();

    /**
     * 获取当前操作系统处理器
     */
    public OSHandler getOSHandler() {
        return osHandlers.stream()
                .filter(x -> OS.contains(x.getOSName()))
                .findFirst()
                .orElse(null);
    }

}